#include "head.h"

int initPool(pool_t *pool, int num)
{
    pool->exitFlag = 0;
    pool->thread_num = num;
    pthread_mutex_init(&pool->lock, NULL);
    pthread_cond_init(&pool->cond, NULL);
    memset(&pool->queue, 0, sizeof(pool->queue));
    pool->thread_ids = (pthread_t *)calloc(num, sizeof(pthread_t));

    for (int i = 0; i < num; i++)
    {
        pthread_create(&pool->thread_ids[i], NULL, threadMain, (void *)pool);
    }
    return 0;
}